#include <iostream>
#include <string>
#include <memory>
#include <stdexcept>
#include <csignal>
#include <sstream>
#include <gflags/gflags.h>
#include <zeroplusmq.h>
#include <yaml-cpp/yaml.h>

using namespace zeroplus::mq;

DEFINE_string(confPath, "", "yaml path");

int main(int argc, char **argv)
{
    gflags::ParseCommandLineFlags(&argc, &argv, true);
    try
    {
        // 加载 YAML 文件
        YAML::Node config = YAML::LoadFile(FLAGS_confPath);
        // 启动
        Uri namesrvUri(config["common"]["scheme"].as<std::string>(),
                       config["common"]["ip"].as<std::string>(),
                       config["nameserver"]["port"].as<std::string>());
        NameSrvController controller(namesrvUri.GetUri());
        controller.Start();
    }
    catch (const YAML::Exception &e)
    {
        std::cerr << "YAML Error: " << e.what() << std::endl;
        return 1;
    }
}